package com.zb.internetSpider.gui;

import java.awt.Color;
import java.awt.Font;
import java.awt.Image;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JTabbedPane;

import org.springframework.stereotype.Component;

import com.zb.internetSpider.utils.CommonUtils;

@Component
public class DefaultTheme implements Theme {

	/**
	 * application的logo
	 */
	private Image logo = null;

	/**
	 * 通用字体
	 */
	private Font commonFont = null;
	
	/**
	 * frame 字体颜色
	 */
	private Color frameFontColor = null;

	/**
	 * 标题
	 */
	private String title = "爬虫";

	/**
	 * 菜单栏字体
	 */
	private Font menuBarFont = null;

	/**
	 * 菜单栏字体颜色
	 */
	private Color menuBarFontColor = null;

	/**
	 * 选项卡字体
	 */
	private Font tabsFont = null;

	/**
	 * 选项卡布局策略
	 */
	private int tabLayoutPolicy = JTabbedPane.SCROLL_TAB_LAYOUT;

	/**
	 * 内容面板字体
	 */
	private Font contentFont = null;

	/**
	 * 页脚字体
	 */
	private Font footerFont = null;

	/**
	 * 侧边栏字体
	 */
	private Font asiderFont = null;

	/**
	 * 菜单树字体
	 */
	private Font menuTreeFont = null;
	
	/**
	 * 获取菜单树字体颜色
	 */
	private Color menuTreeFontColor = Color.BLACK;
	
	/**
	 * 菜单打开节点的图标
	 */
	private Icon menuOpenIcon = null;
	
	/**
	 * 菜单关闭节点的图标
	 */
	private Icon menuCloseIcon = null;
	
	/**
	 * 菜单叶子节点的图标
	 */
	private Icon menuLeafIcon = null;
	

	/**
	 * 页脚背景颜色
	 */
	private Color footerBackGroundColor = null;

	/**
	 * 页脚字体颜色
	 */
	private Color footerFontColor = null;

	/**
	 * 页脚高度
	 */
	private int footerHeight = 36;

	/**
	 * 侧边栏背景颜色
	 */
	private Color asiderBackGroundColor = null;

	/**
	 * 主程序背景颜色
	 */
	private Color mainBackGroundColor = null;

	/**
	 * 菜单栏背景颜色
	 */
	private Color menuBarBackGroudColor = null;

	public DefaultTheme() {
		// TODO Auto-generated constructor stub
		//	设置通用字体
		String fontName = "楷体";
		if(!CommonUtils.isExistFont(fontName)) {
			fontName = CommonUtils.getSystemFontNames()[0];
		}
		
		this.commonFont = new Font(fontName, Font.BOLD, 24);
		this.frameFontColor = Color.RED;		
		
		this.menuTreeFont = new Font(fontName, Font.PLAIN, 15);
		this.menuTreeFontColor = new Color(255,255,255);
		this.menuCloseIcon = new ImageIcon("src/main/resource/img/close.png");
		this.menuOpenIcon = new ImageIcon("src/main/resource/img/expand.png");
		this.menuLeafIcon = new ImageIcon("src/main/resource/img/icon.png");
		
		this.footerFont = new Font(fontName, Font.BOLD, 18);			
		this.contentFont = new Font(fontName, Font.PLAIN, 15);
		this.tabsFont =  new Font(fontName, Font.PLAIN, 16);	
		this.asiderFont = new Font(fontName, Font.PLAIN, 16);
	
		this.asiderBackGroundColor = new Color(51, 51, 51);
		
		this.footerHeight = 56;
		this.footerBackGroundColor = Color.LIGHT_GRAY; 
//				new Color(0,0,0,150);
		this.footerFontColor = new Color(204,204,204);
		
		this.mainBackGroundColor = Color.WHITE;
		this.menuBarBackGroudColor = Color.LIGHT_GRAY;
//				new Color(30,144,255);
		this.menuBarFontColor = Color.BLACK; 
//				new Color(204,204,204);
		this.menuBarFont = new Font(fontName, Font.BOLD, 18);
		
		
		// 设置logo
		 try {
			this.logo = ImageIO.read(new File("src/main/java/logo.png"));
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} 
	}

	@Override
	public Image getLogo() {
		// TODO Auto-generated method stub
		return this.logo;
	}

	@Override
	public Font getCommonFont() {
		// TODO Auto-generated method stub
		return this.commonFont;
	}

	@Override
	public Font getMenuBarFont() {
		// TODO Auto-generated method stub
		return this.menuBarFont;
	}

	@Override
	public Font getMenuTreeFont() {
		// TODO Auto-generated method stub
		return this.menuTreeFont;
	}

	@Override
	public Font getTabsFont() {
		// TODO Auto-generated method stub
		return this.tabsFont;
	}

	@Override
	public Font getContentFont() {
		// TODO Auto-generated method stub
		return this.contentFont;
	}

	@Override
	public Font getFooterFont() {
		// TODO Auto-generated method stub
		return this.footerFont;
	}

	@Override
	public Color getFooterBackGroundColor() {
		// TODO Auto-generated method stub
		return this.footerBackGroundColor;
	}

	@Override
	public Color getAsiderBackGroundColor() {
		// TODO Auto-generated method stub
		return this.asiderBackGroundColor;
	}

	@Override
	public Color getMainBackGroundColor() {
		// TODO Auto-generated method stub
		return this.mainBackGroundColor;
	}

	@Override
	public String getTitle() {
		// TODO Auto-generated method stub
		return this.title;
	}

	@Override
	public int getTabsLayoutPolicy() {
		// TODO Auto-generated method stub
		return this.tabLayoutPolicy;
	}

	@Override
	public Color getMenuBarBackGroundColor() {
		// TODO Auto-generated method stub
		return this.menuBarBackGroudColor;
	}

	@Override
	public Color getFooterFontColor() {
		// TODO Auto-generated method stub
		return this.footerFontColor;
	}

	@Override
	public int getFooterHeight() {
		// TODO Auto-generated method stub
		return this.footerHeight;
	}

	@Override
	public Font getAsiderFont() {
		// TODO Auto-generated method stub
		return this.asiderFont;
	}

	@Override
	public Color getMenuBarFontColor() {
		// TODO Auto-generated method stub
		return this.menuBarFontColor;
	}

	@Override
	public Icon getMenuTreeCloseIcon() {
		// TODO Auto-generated method stub
		return this.menuCloseIcon;
	}

	@Override
	public Icon getMenuTreeOpenIcon() {
		// TODO Auto-generated method stub
		return this.menuOpenIcon;
	}

	@Override
	public Icon getMenuTreeLeafIcon() {
		// TODO Auto-generated method stub
		return this.menuLeafIcon;
	}

	@Override
	public Color getMenuTreeFontColor() {
		// TODO Auto-generated method stub
		return this.menuTreeFontColor;
	}

	@Override
	public Color getFrameFontColor() {
		// TODO Auto-generated method stub
		return this.frameFontColor;
	}

}
